package com.framework.common.utils;


import java.util.Date;
import java.util.concurrent.atomic.AtomicLong;

/**
 * 生成全局唯一序列号工具类
 * @author xfy
 * @date 2020/10/29
 */
public class MySeq {

	private static AtomicLong username_seq = new AtomicLong(0L);

	private static String username_seq_prefix = "yj";


	private static String node = "00";

	/**
	 * 获取全局唯一uuid号
	 * @return
	 */
	public static String getUsername() {
		return getSeq(username_seq_prefix, username_seq);
	}

	private static String getSeq(String prefix, AtomicLong seq) {
			prefix += node;
		return String.format("%s%s%06d", prefix, DateUtils.format(new Date(),"yyyyMMddHHmmss"), (int) seq.getAndIncrement() % 1000000);
	}

}